﻿namespace Innovative.ProXr
{
	public static partial class DirectApi
	{
		/// <summary>
		/// Contains commands that can be performed against a specified bank and relay. These
		/// commands do not require the bank to be selected first.
		/// </summary>
		public static class SelectedRelay
		{
			/// <summary>
			/// Turns off all relays, pauses for a short duration, then activates the selected relay. Since the communication 
			/// bus is limited to 8 bits, this command can accept a byte to control the status of the first 256 relays, or it 
			/// can accept a word, to control the status of more the 256 relays. The optional parameter [0-255] is usually a 
			/// value of 0 or 1 for many controllers, 0 indicating the first 256 relays, 1 indicating the next 256 relays. The 
			/// actual maximum value for this command will depend on the number of relays supported by you controller.
			/// </summary>
			public static RelayCommandSet<bool, int, int> AllOffAndActivate = new RelayCommandSet<bool, int, int>()
			{
				Commands = new RelayCommand[]
				{
					RelayCommand.Command254,
					RelayCommand.CreateReadOnlyCommand(1, 46),
					RelayCommand.CreateNonOptionalParameterCommand(2, (new RelayByte[0]).CreateRange(0, 255)),
					RelayCommand.CreateOptionalParameterCommand(3, (new RelayByte[0]).CreateRange(0, 255))
				},
				ExpectedResults = new RelayByte[] { 85 },
				ResponseConverter = new Boolean85ResponseConverter(),
				Parameter1Converter = new Int32ParameterConverter(),
				Parameter2Converter = new Int32ParameterConverter()
			};

			/// <summary>
			/// Turns off the selected relay. Since the communication bus is limited to 8 bits, this command can accept a byte 
			/// to control the status of the first 256 relays, or it can accept a word, to control the status of more than 256 
			/// relays. The optional parameters [0-255] is usually a value of 0 or 1 for many controllers, 0 indicating the first 
			/// 256 relays, 1 indicating the next 256 relays. The actual maximum value for this command will depend on the number 
			/// of relays supported by your controller.
			/// </summary>
			public static RelayCommandSet<bool, int, int> TurnOff = new RelayCommandSet<bool, int, int>()
			{
				Commands = new RelayCommand[]
				{
					RelayCommand.Command254,
					RelayCommand.CreateReadOnlyCommand(1, 47),
					RelayCommand.CreateNonOptionalParameterCommand(2, (new RelayByte[0]).CreateRange(0, 255)),
					RelayCommand.CreateOptionalParameterCommand(3, (new RelayByte[0]).CreateRange(0, 255))
				},
				ExpectedResults = new RelayByte[] { 85 },
				ResponseConverter = new Boolean85ResponseConverter(),
				Parameter1Converter = new Int32ParameterConverter(),
				Parameter2Converter = new Int32ParameterConverter()
			};

			/// <summary>
			/// Turns on the selected relay. Since the communication bus is limited to 8 bits, this command can accept a byte to 
			/// control the first 256 relays, or it can accept a word to control the status of more than 256 relays. The optional 
			/// parameter of [0-255] is usually a value of 0or 1 for many controllers, 0 indicating the first 256 relay, 1 indicating 
			/// the next 256 relays. The actual maximum value for this command will depend on the number of relays supported by your controller.
			/// </summary>
			public static RelayCommandSet<bool, int, int> TurnOn = new RelayCommandSet<bool, int, int>()
			{
				Commands = new RelayCommand[]
				{
					RelayCommand.Command254,
					RelayCommand.CreateReadOnlyCommand(1, 48),
					RelayCommand.CreateNonOptionalParameterCommand(2, (new RelayByte[0]).CreateRange(0, 255)),
					RelayCommand.CreateOptionalParameterCommand(3, (new RelayByte[0]).CreateRange(0, 255))
				},
				ExpectedResults = new RelayByte[] { 85 },
				ResponseConverter = new Boolean85ResponseConverter(),
				Parameter1Converter = new Int32ParameterConverter(),
				Parameter2Converter = new Int32ParameterConverter()
			};
		}
	}
}
